#ifndef _SMP_MSGBOX_H
#define _SMP_MSGBOX_H

#include "sgl_funcs.h"
#include "sgl_window.h"

enum {
	SMP_MSGBOX
	//,SMP_MSGBOX_WNDPROC
};

#ifndef SDK_NO_PLUGIN
#define SMP_MSGBOX_WNDPROC  MPS_CODE_SMP_MSGBOX_PROC
#else
#define SMP_MSGBOX_WNDPROC  SMP_MsgBox_WndProc
#endif

/**
  \defgroup smp_msgbox Simple MsgBox

  To work with the simple msgbox:
  - Show the msgbox 
  - Response the notify message

  \code
  	//just call this function to show the msgbox
  	SMP_MsgBox(...);

  	//response the notify message
	case WM_COMMAND:
		WID id = LOWORD(wParam);
		WORD code = HIWORD(wParam);

		if(id == "the msgbox id")
		{
			HWND hMsgbox = (HWND)lParam;
			if(code == ID_OK)
			{
				//press ok
			}else{
				//press cancel
			}
		}	
  \endcode

  @ingroup controls
  @{
*/

	/**
	* \name Window Styles
	* @{
	*/

/**
 *\brief the Types of message box
 */

enum {
	MSGBOX_TYPE_NOTI,
	MSGBOX_TYPE_WAITTING,
	MSGBOX_TYPE_QUERY,
	MSGBOX_TYPE_ERROR
};

#define MSGBOX_ICON_WIDTH    44

/**
 * \brief Identifer Non.
 */
#define ID_NON		0 //when modal window close by the window manangement system

/**
 * \brief Indicates the msgbox has the ok button.
 */
#define ID_OK		0x0001L

/**
 * \brief Indicates the msgbox has the cancel button.
 */
#define ID_CANCEL	0x0002L

/**
 * \brief Indicates the msgbox button should be "YES/NO"
 */
#define ID_YESNO	0x0004L

/**
 * \brief Indicates the msgbox can terminate itself after a specific interval.
 *
 * This style can just only used when the msgbox only has less than one button.
 */
#define SMP_MSGBOXS_AUTOCLOSE		0x0008L

#define SMP_MSGBOXS_WAITBAR 			0x0020L

	/** @} */

/**
 * \brief The close timer interval to close the msgbox.
 *
 * when the msgbox only has one button, 
 * the msgbox will terminate after SMP_MSGBOX_AUTOCLOSE_INTERVAL ms.
 */
#define SMP_MSGBOX_AUTOCLOSE_INTERVAL	3000 //ms

	/**
	 * \name Window Member Functions
	 * @{
	 */

#if defined(INCLUDE_IN_PLUG_SGL_SRC) || defined(SDK_NO_PLUGIN)
/**
 * \brief Show a Message box.
 *
 * \param id the msg box id
 * \param hParent the top-level window handle
 * \param hBmp the icon
 * \param title the title string
 * \param content the content string
 * \param style the window style and buttons could be the | value of ID_OK, ID_CANCEL, ID_YESNO
 * \param listener who receive the notify message, parenter will get the messages when it is NULL
 */
//HWND SMP_MsgBox(PWNDATTR attr, int32 type, PCWSTR content);
HWND SMP_MsgBoxEx(PWNDATTR attr, int32 type, PCWSTR content, HWND hChild);

	/** @} */
	
	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief The msgbox window procedure.
 *
 * \param hDlg the window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
LRESULT SMP_MsgBox_WndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
#else

/**
 * \brief Show a Message box.
 *
 * \param id the msg box id
 * \param hParent the top-level window handle
 * \param hBmp the icon
 * \param title the title string
 * \param content the content string
 * \param style the window style and buttons could be the | value of ID_OK, ID_CANCEL, ID_YESNO
 * \param listener who receive the notify message, parenter will get the messages when it is NULL
 */
//HWND SMP_MsgBox(WID id, HWND hParent, HBITMAP hBmp, PCWSTR title, PCWSTR content, DWORD style, HWND listener);
/*
#define SMP_MsgBox(attr, hBmp, title, content) \
	(HWND)mrc_extSendAppEventEx(MPS_CODE_SMP_MSGBOX, SMP_MSGBOX, (int32)attr, (int32)hBmp, (int32)title, (int32)content, (int32)0)
*/
#define SMP_MsgBoxEx(attr, type, content, hChild) \
	(HWND)mrc_extSendAppEventEx(MPS_CODE_SMP_MSGBOX, SMP_MSGBOX, (int32)attr, (int32)type, (int32)content, (int32)hChild, (int32)0)


//HWND SMP_Show_MsgBox(WID id, HWND hParent, HBITMAP hBmp, PCWSTR title, PCWSTR content, DWORD style, HWND listener);
/*
HWND Show_MsgBox(WID id, HWND hParent, HBITMAP hBmp, PCWSTR title, PCWSTR content, DWORD style, HWND listener)
{
	WND_ATTR attr;
	attr.id = id;
	attr.style = style;
	attr.hParent = hParent;
	attr.listener = listener;
	return SMP_MsgBox(&attr, NULL, title, content);
}
*/

	/** @} */
	
	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief The msgbox window procedure.
 *
 * \param hDlg the window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
#define SMP_MsgBox_WndProc(hDlg, Msg, wParam, lParam) \
	(LRESULT)mrc_extSendAppEventEx(MPS_CODE_SMP_MSGBOX_PROC, (int32)hDlg, (int32)Msg, (int32)wParam, (int32)lParam, (int32)0, (int32)0)
#endif
	/** @} */

#define SMP_MsgBox(attr, type, content) 	SMP_MsgBoxEx(attr, type, content, NULL)

/** @} end of smp_msgbox */

#endif /* _SMP_MSGBOX_H */

